#coding=utf-8
import random
from typing import Union, Any

ran=random.randint(0, 100)
gold = 100
while gold>0:
    print("您现在拥有的金币为", gold)
    a=input("请输入一个0~100的数字:")
    if a.isdigit():
        a=int(a)
        if a <=100 and  a>=0:
            if a ==ran:
                print("恭喜猜对了")
                gold=gold+50
                print("您现在拥有的金币为:",gold)
            elif a>ran:
                print("猜大了")
                gold=gold-20
                print("您现在拥有的金币为:",gold)
            elif a<ran:
                print("猜小了")
                gold: Union[int, Any]=gold-20
                print("您现在拥有的金币为:",gold)
            elif gold<20:
                break
        else:
            print("超出范围")
    else:
        print("非法字符")
